import React ,{Component} from "react";
import { Space, Select, Tag, Input, Button ,Row, Divider,Col } from "antd";
import parse from 'html-react-parser';
import './index.css';
import getData from '../../../compontens/GetData/getData.jsx';

export default class KronaItem extends React.Component{
    constructor(props){
        super(props);
        this.state = {
            data: '',
            kra_result: {},
            options: [],
        }
    }
    get_data = (file_Name) => {
        getData(file_Name)
        .then(result => {
          // 在这里处理返回的数据
          const data = result;
          console.log(data);
          this.setState({data: data});
        })
        .catch(error => {
          alert('Error');
        });
    };
    componentDidMount(){
        // const kra_result = localStorage.getItem('kra_result');
      const kra_result =  {
        "IDList": ["M0018C_2_month", "M0018C_1_month", "M0018C_3_month", "M0018C_14_day", "M0018C_birth", "M0018M_3_month", "M0018M_gest", "M0018M_birth"],
        "kra_path": "data/Result/1/Kraken_result",
        "result_path": "data/Result/1",
        "sankey_path": "data/Result/1/sankey",
        "krona_path": "data/Result/1/Krona_result",
        "classification_path": "data/Result/1/Kraken_result",
        "diversity_path": "data/Result/1/diversity"
      }
      if(!kra_result){
        return;
      }

      const options = kra_result.IDList.map((item) => {
        return {
          value: item,
          label: item,
        }
      })
      const defaultValue = kra_result.IDList[0];
      this.setState({
        kra_result: kra_result,
        options : options,
        defaultValue: defaultValue,
      })
      const file_Name = kra_result.krona_path +'/' + kra_result.IDList[0] + '.html';
      this.get_data(file_Name);
    }
    handleChange = (value) => {
      const file_Name = this.state.kra_result.krona_path +'/' + value + '.html';
      this.get_data(file_Name);
    };

    render(){
        const {data, options} = this.state;
        const defaultValue = localStorage.getItem('defaultValue')
        return(
            <div>
                    {/* <Select 
                        style={{
                            width: "100%",
                            textAlign: "center",
                            display: "flex",
                            alignItems: "center",
                            justifyContent: "center"
                        }}
                        defaultValue={defaultValue} options={options} onChange={this.handleChange}/> */}
                        {/* {parse(data)} */}
                        {/* <div dangerouslySetInnerHTML={{ __html: data }} /> */}
                    
                     <iframe src="/textkrona.html" className='frame_style' width="100%" height="800px"></iframe>
                
            </div>
        )
    }
}